<template>
  <div v-loading="loading" class="email_set_box enterprise_email">
    <div v-if="list">
      <MailList @addEmail="addEmail" @categore="categore" @mailEdit="mailEditFun" @exclusiveSeatFun="exclusiveSeatFun" ></MailList>
    </div>
    <div v-if="add">
      <MailAdd @cancel="cancel" @refresh="refreshList"></MailAdd>
    </div>
    <div v-if="Categore">
      <MailCategory @cancel="cancel" @submit="categorySubmit" :categoreInfo="categoreInfo" :categoreFlag="Categore"></MailCategory>
    </div>
    <div v-if="mailEdit">
      <MailEdit @cancel="cancel"  @update="updateMail" :editObject="editObject"></MailEdit>
    </div>
    <div v-if="exclusiveSeat">
      <MailExclusiveSeat @cancel="cancel" :exclusiveSeatData="exclusiveSeatData"></MailExclusiveSeat>
    </div>
  </div>
</template>
<script>
  import MailList from './FirmMailList.vue'
  import MailAdd from './FirmMailAdd.vue'
  import MailCategory from './FirmMailCategorySet.vue'
  import MailEdit from './FirmMailEdit.vue'
  import MailExclusiveSeat from './FirmMailExclusiveSeat'
  function getMailStatus (store, data) {
    return store.dispatch('getMailStatus', data)
  }

  export default {
    name: 'FirmMail',
    data () {
      return {
        list: true,
        add: false,
        Categore: false,
        mailEdit: false,
        loading: true,
        editObject: {},
        categoreInfo: {},
        exclusiveSeat: false,
        exclusiveSeatData: {}
      }
    },
    methods: {
      fetchData () {
        this.loading = false
      },
//      添加企业客服邮箱
      addEmail () {
        this.list = false
        this.add = true
        this.Categore = false
        this.mailEdit = false
        this.exclusiveSeat = false
      },
      // 专属座席设置。
      exclusiveSeatFun (data) {
        this.exclusiveSeat = true
        this.list = false
        this.add = false
        this.Categore = false
        this.mailEdit = false
        this.exclusiveSeatData = data
      },
//      邮箱归类设置
      categore (data) {
        this.list = false
        this.add = false
        this.Categore = true
        this.mailEdit = false
        this.exclusiveSeat = false
        this.categoreInfo = data
      },
//      取消/返回到邮箱list
      cancel () {
        this.list = true
        this.add = false
        this.Categore = false
        this.mailEdit = false
        this.exclusiveSeat = false
        this.refreshList()
      },
//      修改邮箱信息
      mailEditFun (data) {
        this.list = false
        this.add = false
        this.Categore = false
        this.mailEdit = true
        this.exclusiveSeat = false
        this.editObject = data
      },
//      刷新邮箱list
      refreshList () {
        getMailStatus(this.$store, {})
      },
//      邮件分类提交
      categorySubmit () {
      },
//      更新企业邮箱
      updateMail () {

      }
    },
    beforeMount () {
      this.fetchData()
    },
    components: {
      MailList,
      MailAdd,
      MailCategory,
      MailEdit,
      MailExclusiveSeat
    }
  }
</script>
<style lang="stylus" scoped>
  @import "../../../../../assets/common.styl"
</style>
